package com.jingming.consult.network;


import com.jingming.consult.bean.BaseBean;
import com.jingming.consult.bean.JokeBean;
import com.jingming.consult.bean.usercenter.UserInfo;
import com.jingming.consult.network.utils.ObjectLoader;
import com.jingming.consult.network.utils.RetrofitUtil;

import java.util.ArrayList;

import io.reactivex.Observable;

/**
 * 网络请求
 */
public class MobileApi extends ObjectLoader {

    private MobileApiInterface mobileApiInterface;

    private MobileApi() {
        mobileApiInterface = RetrofitUtil.getInstance().create(MobileApiInterface.class);
    }

    public static MobileApi getInstance() {
        return SingletonHolder.INSTANCE;
    }

    private static class SingletonHolder {
        public static MobileApi INSTANCE = new MobileApi();
    }

    /**
     * 获取消息
     */
    public Observable<BaseBean> communal4_tabAd(String code, int location) {
        return observe(mobileApiInterface.getnotice(code, location));
    }

    /**
     * 登录
     */
    public Observable<BaseBean<UserInfo>> communal4_tabAdOnly(UserInfo userInfo) {
        return observe(mobileApiInterface.login(userInfo));
    }

    /**
     * @param page 页码
     * @param count 数量
     * @param type 类型 video
     * @return Object
     */
    public Observable<BaseBean<ArrayList<JokeBean>>> getJoke(int page, int count, String type) {
        return observe(mobileApiInterface.getJoke(page, count, type));

    }

}
